package com.cdks.wuxiu.api.component.agora;


import cn.hutool.core.codec.Base64;
import io.agora.media.RtcTokenBuilder2;
import io.agora.media.RtcTokenBuilder2.Role;


public class AgoraUtil {
    public static String getCallToken(String uid, String channelName)
    {
        RtcTokenBuilder2 token = new RtcTokenBuilder2();
        
        return token.buildTokenWithUserAccount(AgoraConfig.appId, AgoraConfig.appCertificate, channelName, uid, Role.ROLE_SUBSCRIBER, AgoraConfig.tokenExpirationInSeconds, AgoraConfig.privilegeExpirationInSeconds);
    }

    public static String getCallToken(int uid, String channelName)
    {
        RtcTokenBuilder2 token = new RtcTokenBuilder2();
        
        return token.buildTokenWithUid(AgoraConfig.appId, AgoraConfig.appCertificate, channelName, uid, Role.ROLE_SUBSCRIBER, AgoraConfig.tokenExpirationInSeconds, AgoraConfig.privilegeExpirationInSeconds);
    }

    public static String getBasicAuth()
    {
		// 使用 RTC 的服务端 RESTful API
		// 客户 ID
		String customerKey  = "0975dc3f0a224a04996750c22082e288";
		// 客户密钥
		String customerSecret  = "651919e9cc244d0587d76b3bfd4b4a32";
		// 使用 base64 进行编码
		return Base64.encode((customerKey + ":" + customerSecret));
    }
}
